package il.ac.braude.sona.gui.mytables;

import il.ac.braude.sona.control.ReportsController;
import il.ac.braude.sona.entities.PeriodicReport;
import il.ac.braude.sona.gui.list_table.ListTable;
import il.ac.braude.sona.gui.list_table.ListTableClickAdapter;
import il.ac.braude.sona.gui.list_table.ListTableFrame;
/**
 * The ReportsTableFrame creates GUI for viewing list of saved reports in system
 * @author  Ofek Ron
 * @author Avihay Avitan
 * @author Nitzan Inbar
 * @author Sasha Rozenthal
 * Group 6,<br>Laboratory in Software Engineering,Ort Braude College.</p>
 *
 */
public class ReportsTableFrame extends ListTableFrame<PeriodicReport> {
	/**
	 * the reports controller
	 */
	private ReportsController control;
	
	/**
	 * Constructs the ReportsTableFrame 
	 * @param reportsController - the reports controller
	 */
	public ReportsTableFrame(ReportsController reportsController) {
		super("Periodic Reports");
		control=reportsController;
	}
	@Override
	public void setTable(ListTable<PeriodicReport> table) {
		super.setTable(table);
		listTable.addListTableClickListener(new ListTableClickAdapter<PeriodicReport>() {
			@Override
			public void onDoubleClick(PeriodicReport t) {
				control.periodicReport(t,"Periodic Report");
				ReportsTableFrame.this.dispose();
			}
		});
	}

}
